﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SupervisorController;

namespace SupervisorGUI
{
    /// <summary>
    /// Interaction logic for ChangePasswordWindow.xaml
    /// </summary>
    public partial class ChangePasswordWindow : Window
    {
        string oldPassword, newPassword;
        Cls_SupervisorController supervisorController;

        public ChangePasswordWindow(Cls_SupervisorController supervisorController)
        {
            InitializeComponent();
            this.supervisorController = supervisorController;
        }

        private void btnPassword_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                oldPassword = txtOldPassword.Text;
                newPassword = txtNewPassword.Text;

                if (supervisorController.ChangePassword(oldPassword, newPassword))
                    MessageBox.Show("Password is Changed", "Password is Changed",MessageBoxButton.OK,MessageBoxImage.Information);
                else
                    MessageBox.Show("Wrong Password!", "Wrong Password!",MessageBoxButton.OK,MessageBoxImage.Error);

                txtOldPassword.Clear();
                txtNewPassword.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
